-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[wasm][coreclr] Fix reflection with large valuetypes #123759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I am also writing down my thoughts on #120791 and will add them soon |
|
Tagging subscribers to this area: @mangod9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the WASM/CoreCLR interpreter calling convention support so reflection invoke can correctly pass/return large value types (notably SIMD vectors), including adjusting the special-argument ordering (retbuf vs this) and improving stack layout alignment.
Changes:
- Adjust WASM reflection invoke/call-descriptor plumbing to account for retbuf presence and interpreter stack-slot sizing.
- Update ArgIterator WASM logic for special-arg offsets and value-type alignment handling.
- Fix a test failure message to correctly reference
Vector128<T>.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/JIT/Directed/VectorABI/VectorMgdMgdArray.cs | Updates failure message text to reflect Vector128<T> checks. |
| src/coreclr/vm/wasm/cgencpu.h | Refines return-type size macros used by calling convention logic. |
| src/coreclr/vm/wasm/calldescrworkerwasm.cpp | Adjusts interpreter call argument pointer/size handling when a retbuf is present. |
| src/coreclr/vm/reflectioninvocation.cpp | Updates stack-slot counting and records retbuf presence for WASM reflection calls. |
| src/coreclr/vm/frames.cpp | Recomputes this offset via ArgIterator instance (signature-aware). |
| src/coreclr/vm/callingconvention.h | Makes GetThisOffset instance-based; updates WASM special-arg ordering and adds valuetype alignment logic. |
| src/coreclr/vm/callhelpers.h | Adds hasRetBuff field (WASM-only) to CallDescrData. |
| src/coreclr/vm/callhelpers.cpp | Initializes hasRetBuff for WASM call paths and adds a debug assert. |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
| ## Incoming argument ABI | ||
|
|
||
| The linear stack pointer `$sp` is the first argument to all methods. At a native->managed transition it is the value of the `$__stack_pointer` global. This global may be updated to the current `$sp` within managed code, and must be up to date with the current `$sp` at managed->native boundaries. Within the method the stack pointer always points at the bottom (lowest address) of the stack; generally this is a fixed offset from the value the stack pointer held on entry, except in methods that can do dynamic allocation. | ||
| The linear stack pointer `$sp` is the first argument after the managed `this` argument or the first argument for static methods. At a native->managed transition it is the value of the `$__stack_pointer` global. This global may be updated to the current `$sp` within managed code, and must be up to date with the current `$sp` at managed->native boundaries. Within the method the stack pointer always points at the bottom (lowest address) of the stack; generally this is a fixed offset from the value the stack pointer held on entry, except in methods that can do dynamic allocation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better for stack pointer to be argument 0 so that it is always in a fixed position, and for this to be to after that (if it is present) so that it is in fixed position too.
Implement return of large valuetypes from reflection calls and also large valuetypes arguments.
Change the order of
thisandretbufarguments. This goes toward the #120791 and the new calling convention. It also helps to keep the interpreter calls use simple memory copy.JIT/Directed/Directed_3 runtime tests were used as repro.
Fixes #122922